local poyuan = fk.CreateSkill{
    name = "wk_heg__poyuan",
}

Fk:loadTranslationTable{
    ["wk_heg__poyuan"] = "破垣",
    [":wk_heg__poyuan"] = "①当你对其他角色造成伤害后，你可弃置其一张装备区内的牌；②当你于回合内首次对大势力角色造成伤害时，此伤害+1。",

    ["#wk_heg__poyuan-discard"] = "破垣：是否弃置受伤角色装备区内一张牌",
    ["poyuan_discard-hand"] = "令其弃置一张手牌",
    ["poyuan_discard-equip"] = "弃置其一张装备区内的牌",

    ["$wk_heg__poyuan1"] = "砲石飞空，坚垣难存。",
    ["$wk_heg__poyuan2"] = "声若霹雳，人马俱摧。",
}

local H = require "packages.ol_hegemony.util"

poyuan:addEffect(fk.Damage,{
  anim_type = "offensive",
  can_trigger = function (self, event, target, player, data)
    if not (target == player and player:hasSkill(poyuan.name) and player:isAlive()) then return false end
    return data.to ~= player and not data.to.dead and #data.to:getCardIds("e") > 0
  end,
  on_cost = function (self, event, target, player, data)
    return player.room:askToSkillInvoke(player, {skill_name = poyuan.name, prompt = "#wk_heg__poyuan-discard",})
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local id = room:askToChooseCard(player,{
      target = data.to,
      flag = "e",
      skill_name = poyuan.name,
    })
    room:throwCard(id, poyuan.name, data.to, player)
  end,
})

poyuan:addEffect(fk.DamageCaused,{
  anim_type = "offensive",
  can_trigger = function (self, event, target, player, data)
  if not (target == player and player:hasSkill(poyuan.name) and player:isAlive()) then return false end
      if not (H.isBigKingdomPlayer(data.to) and player.room.current == player) then return false end
      local events = player.room.logic:getActualDamageEvents(1, function(e)
      return 
        e.data.from == player and e.data.to and H.isBigKingdomPlayer(e.data.to) 
      end, Player.HistoryTurn)
    return #events == 0 and player:getMark("wk_heg__poyuan-turn") == 0
  end,
  on_cost = function (self, event, target, player, data)
      return true
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    data:changeDamage(1)
    room:setPlayerMark(player, "wk_heg__poyuan-turn", 1)
  end,
})

return poyuan